package com.ysy.tz.core.validator;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javafx.scene.Node;

public class StyleClassDecoration implements Decoration {
    private final Set<String> styleClasses;

    public StyleClassDecoration(String... styleClasses) {
        if (styleClasses != null && styleClasses.length != 0) {
            this.styleClasses = new HashSet(Arrays.asList(styleClasses));
        } else {
            throw new IllegalArgumentException("At least one style class is required");
        }
    }

    public void add(Node targetNode) {
        List<String> styleClassList = targetNode.getStyleClass();
        Set<String> toAdd = new HashSet(this.styleClasses);
        toAdd.removeAll(styleClassList);
        styleClassList.addAll(toAdd);
    }

    public void remove(Node targetNode) {
        targetNode.getStyleClass().removeAll(this.styleClasses);
    }
}
